package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.itheima.mapper.PermissionMapper;
import com.itheima.pojo.Approval;
import com.itheima.pojo.Permission;
import com.itheima.pojo.Result;
import com.itheima.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements PermissionService {
    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public Result<Page> selectPage(Page page,Integer enVisible) {
        // 创建 LambdaQueryWrapper 来构造查询条件
        LambdaQueryWrapper<Permission> permissionLambdaQueryWrapper = new LambdaQueryWrapper<>();
        // 查询条件是权限状态0停用1启用
        if (enVisible != null) {
            permissionLambdaQueryWrapper.eq(Permission::getEnVisible, enVisible);
        }
        // 调用 Mapper 的 selectPage 方法进行分页查询
        Page page1 = permissionMapper.selectPage(page, permissionLambdaQueryWrapper);
        return Result.success(page1);
    }

}
